<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
require 'db_conn.php';
//收集留言，显示出来
/*echo $_POST["username"]."<br/>";
echo $_POST["sex"]."<br/>";
echo $_POST["message"]."<br/>";
echo $_POST["imgurl"]."<br/>";*/
$username=$_POST["username"];
$sex=$_POST["sex"];
$message=$_POST["message"];
$imgurl=$_POST["imgurl"];
//写
$sql="insert into t_message(username,sex,message,imgurl) values('$username','$sex','$message','$imgurl')";
 $result=$db->query($sql);//
 
 if ($result)
 {
     echo "<script language='javascript' type='text/javascript'>";
     echo "alert('留言成功');";
     echo "window.location.href='index.php';";
     echo "</script>";
 }
 else {
     echo "<script language='javascript' type='text/javascript'>";
     echo "alert('留言失败！');";
     echo "window.location.href='index.php';";
     echo "</script>";
        }

// header("location:index.php");